package org.jivesoftware.smackx.pubsub;

import java.util.Iterator;
import java.util.List;
import org.jivesoftware.smack.packet.PacketExtension;

public class ItemsExtension extends NodeExtension
  implements EmbeddedPacketExtension
{
  protected List<? extends PacketExtension> items;
  protected Boolean notify;
  protected ItemsElementType type;

  public ItemsExtension(String paramString, List<? extends PacketExtension> paramList, boolean paramBoolean)
  {
    super(ItemsElementType.retract.getNodeElement(), paramString);
    this.type = ItemsElementType.retract;
    this.items = paramList;
    this.notify = Boolean.valueOf(paramBoolean);
  }

  public ItemsExtension(ItemsElementType paramItemsElementType, String paramString, List<? extends PacketExtension> paramList)
  {
    super(paramItemsElementType.getNodeElement(), paramString);
    this.type = paramItemsElementType;
    this.items = paramList;
  }

  public List<PacketExtension> getExtensions()
  {
    return getItems();
  }

  public List<? extends PacketExtension> getItems()
  {
    return this.items;
  }

  public ItemsElementType getItemsElementType()
  {
    return this.type;
  }

  public boolean getNotify()
  {
    return this.notify.booleanValue();
  }

  public String toString()
  {
    return getClass().getName() + "Content [" + toXML() + "]";
  }

  public String toXML()
  {
    String str;
    if ((this.items == null) || (this.items.size() == 0))
    {
      str = super.toXML();
      return str;
    }
    StringBuilder localStringBuilder = new StringBuilder("<");
    localStringBuilder.append(getElementName());
    localStringBuilder.append(" node='");
    localStringBuilder.append(getNode());
    if (this.notify != null)
    {
      int i;
      localStringBuilder.append("' ");
      localStringBuilder.append(this.type.getElementAttribute());
      localStringBuilder.append("='");
      if (this.notify.equals(Boolean.TRUE))
        i = 1;
      while (true)
      {
        while (true)
        {
          localStringBuilder.append(i);
          localStringBuilder.append("'>");
          localStringBuilder.append("</");
          localStringBuilder.append(getElementName());
          localStringBuilder.append(">");
          str = localStringBuilder.toString();
        }
        i = 0;
      }
    }
    localStringBuilder.append("'>");
    Iterator localIterator = this.items.iterator();
    while (true)
    {
      if (!(localIterator.hasNext()));
      localStringBuilder.append(((PacketExtension)localIterator.next()).toXML());
    }
  }

  public static enum ItemsElementType
  {
    private String att;
    private PubSubElementType elem;

    static
    {
      ItemsElementType[] arrayOfItemsElementType = new ItemsElementType[2];
      arrayOfItemsElementType[0] = items;
      arrayOfItemsElementType[1] = retract;
      ENUM$VALUES = arrayOfItemsElementType;
    }

    public String getElementAttribute()
    {
      return this.att;
    }

    public PubSubElementType getNodeElement()
    {
      return this.elem;
    }
  }
}